# U-Boot: PLX/Oxford Semiconductor NAS7820
# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>

buildarch=2

pkgname=uboot-oxnas
pkgver=2013.10
pkgrel=2
pkgdesc="U-Boot for PLX/Oxford Semiconductor NAS7820"
arch=('arm')
url="https://github.com/linux-sunxi/u-boot-sunxi/tree/sunxi-current"
license=('GPL')
_commit=a0140080d966a080fe0c7f5e3a5a84856e02a32e
source=("https://github.com/kref/u-boot-oxnas/archive/${_commit}.tar.gz"
        'alarm.patch'
        'packager'
        'flash')
md5sums=('27d8094d90aaffcbf7527f963f498504'
         '0633e9da16f0fd4957883b55e67900c8'
         '9c38473d3e0168eefe38f41413bd77d8'
         'fe2586f3eeb43b5b533e9e85175d13f9')

prepare() {
  cd u-boot-oxnas-${_commit}
  patch -p1 -i "${srcdir}"/alarm.patch
}

build() {
  cd u-boot-oxnas-${_commit}
  
  unset CFLAGS CXXFLAGS LDFLAGS
  
  make distclean
  make ox820_ext4_config
  make u-boot.{bin,img} spl/u-boot-spl.bin
  ../packager u-boot.{bin,wrapped} || true
}

package() {
  mkdir -p "${pkgdir}"/boot
  cp u-boot-oxnas-${_commit}/{u-boot.{wrapped,img},spl/u-boot-spl.bin} "${pkgdir}"/boot
  cp flash "${pkgdir}"/boot
}
